package com.liuc.practice.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @Author Liu Chang
 * @Date 2021/5/21 8:19 下午
 */
public class Handler {
    private Object controller; // 因为 handler 方法在 controller 类中， method.invoke(obj, )

    private Pattern url; // url 支持正则表达式

    private Method method; // 匹配的方法

    private Map<String, Integer> paramsIndexMapping; // 参数顺序

    private String[] authority; // 存储当前 handler 中有权限的用户名

//    public Handler(Object controller, Pattern url, Method method) {
//        this.controller = controller;
//        this.url = url;
//        this.method = method;
//        paramsIndexMapping = new HashMap<>();
//    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Pattern getUrl() {
        return url;
    }

    public void setUrl(Pattern url) {
        this.url = url;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Map<String, Integer> getParamsIndexMapping() {
        return paramsIndexMapping;
    }

    public void setParamsIndexMapping(Map<String, Integer> paramsIndexMapping) {
        this.paramsIndexMapping = paramsIndexMapping;
    }

    public String[] getAuthority() {
        return authority;
    }

    public void setAuthority(String[] authority) {
        this.authority = authority;
    }
}
